HA$PBExportHeader$w_tablas_help.srw
forward
global type w_tablas_help from window
end type
type cb_cancelar from commandbutton within w_tablas_help
end type
type em_buscar from editmask within w_tablas_help
end type
type ddlb_1 from dropdownlistbox within w_tablas_help
end type
type dw_1 from datawindow within w_tablas_help
end type
type cb_aceptar from commandbutton within w_tablas_help
end type
end forward

global type w_tablas_help from window
integer width = 2514
integer height = 1596
boolean titlebar = true
string title = "Untitled"
boolean controlmenu = true
windowtype windowtype = response!
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
cb_cancelar cb_cancelar
em_buscar em_buscar
ddlb_1 ddlb_1
dw_1 dw_1
cb_aceptar cb_aceptar
end type
global w_tablas_help w_tablas_help

type variables
string is_columna,isa_columna[],is_codigo,is_tipoColumna
long il_codigo
integer ii_codigo
s_parm2 istr_parm
BOOLEAN ib_Indicador_Cierre = false 
end variables

forward prototypes
public subroutine of_cargar_columnas (datawindow adw)
public subroutine of_filtrar (string as_cadena, string as_columna)
end prototypes

public subroutine of_cargar_columnas (datawindow adw);ddlb_1.reset( )
string ls_syntax, ls_cadena, ls_temp 
long ld_pos, ld_pos_ini, ld_pos_fin
Integer li_fila
ls_syntax = adw.Describe("DataWindow.Syntax")
/* Recupera el nombre de las columnas */
ld_pos = 1
ls_cadena = ''
li_fila =1
Do While ld_pos > 0
	
	ld_pos = pos(ls_syntax, 'text', ld_pos)
	If ld_pos > 0 Then
		ld_pos_ini = pos(ls_syntax, 'name=', ld_pos)
		ld_pos_fin = pos(ls_syntax, ' ', ld_pos_ini)
		ls_temp = ls_cadena +' '+ mid(ls_syntax, ld_pos_ini+5, ld_pos_fin - ld_pos_ini - 5 )
		If Right(ls_temp, 2)='_t' Then 	

			isa_columna[li_fila]= Trim(Left(ls_temp, Len(ls_temp)-2))
			//-- las etiquetas
			ld_pos_ini = pos(ls_syntax, 'text="', ld_pos_fin)
			ld_pos_fin = pos(ls_syntax, '"', ld_pos_ini+7)
			ddlb_1.additem(Trim(mid(ls_syntax, ld_pos_ini+6, ld_pos_fin - ld_pos_ini -6)))
			li_fila ++
		End If
			
		ld_pos = ld_pos_fin
	End If
Loop
ddlb_1.selectitem( 1)
ddlb_1.event selectionchanged(1)
Return


end subroutine

public subroutine of_filtrar (string as_cadena, string as_columna);string ls_cad,ls_tipo,ls_col
if as_cadena = ""  then
		this.dw_1.SetFilter("")
else
		ls_col = this.dw_1.describe(as_columna+'.name')
		ls_tipo=this.dw_1.describe(ls_col+'.coltype')
		ls_cad = 'Upper(string('+ls_col+')) like "%'+Upper(as_cadena)+'%" '
		this.dw_1.SetFilter(ls_cad)	
end if
this.dw_1.filter()
end subroutine

on w_tablas_help.create
this.cb_cancelar=create cb_cancelar
this.em_buscar=create em_buscar
this.ddlb_1=create ddlb_1
this.dw_1=create dw_1
this.cb_aceptar=create cb_aceptar
this.Control[]={this.cb_cancelar,&
this.em_buscar,&
this.ddlb_1,&
this.dw_1,&
this.cb_aceptar}
end on

on w_tablas_help.destroy
destroy(this.cb_cancelar)
destroy(this.em_buscar)
destroy(this.ddlb_1)
destroy(this.dw_1)
destroy(this.cb_aceptar)
end on

event open;
istr_parm=message.powerobjectparm

This.Title = 'Listado de ' + istr_parm.string_parm[2]
setnull(is_codigo)
setnull(ii_codigo)
setnull(il_codigo)

dw_1.dataobject = istr_parm.string_parm[1]
istr_parm.char_parm[1]='0'
dw_1.settransobject(SQLCA)
of_cargar_columnas(dw_1)
dw_1.retrieve();commit;



//s_parm lstr_parm
//
//lstr_parm = Message.PowerObjectParm

//This.Title = 'Listado de ' + lstr_parm.string_parm[2]
////uo_buscar.uf_settitle("Custom062!","&Buscar")
//setnull(is_analisis)
//setnull(ii_analisis)
//setnull(il_analisis)

//dw_listado.SetTransObject(SQLCA)

//If dw_listado.Retrieve(lstr_parm.string_parm[1]) = 0 Then
//	uo_aceptar.Enabled = False
//	uo_buscar.Enabled = False
//End If
end event

event close;if not ib_Indicador_Cierre then
	ib_Indicador_Cierre = True
	closewithreturn(this,istr_parm)
end if
end event

type cb_cancelar from commandbutton within w_tablas_help
integer x = 2085
integer y = 1392
integer width = 402
integer height = 112
integer taborder = 20
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "&Cancelar"
end type

event clicked;setnull(is_codigo)
setnull(ii_codigo)
setnull(il_codigo)

ib_Indicador_Cierre = True
closewithreturn(parent,istr_parm)
end event

type em_buscar from editmask within w_tablas_help
event enchange pbm_enchange
integer x = 805
integer y = 4
integer width = 1682
integer height = 88
integer taborder = 20
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
maskdatatype maskdatatype = stringmask!
end type

event enchange;of_filtrar(this.text,is_columna)
end event

type ddlb_1 from dropdownlistbox within w_tablas_help
integer width = 795
integer height = 400
integer taborder = 10
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
end type

event selectionchanged;is_columna = isa_columna[index] //this.text(index)
em_buscar.text=''
em_buscar.setfocus( )
end event

type dw_1 from datawindow within w_tablas_help
event ue_retrieve ( long al_param )
integer y = 96
integer width = 2501
integer height = 1288
integer taborder = 10
string title = "none"
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

event ue_retrieve(long al_param);string ls_columna,ls_codigo,ls_tipo
//is_codigo=this.object.data(//this.getitemstring(al_param,"cc_analis")
integer li_codigo
long ll_codigo
ls_columna = dw_1.describe('#'+string(1)+'.name')
is_tipoColumna = dw_1.describe(ls_columna+'.coltype')	
If left(is_tipoColumna,4)='char' Then
	 is_codigo =dw_1.object.data[1,1]
Elseif is_tipoColumna='int' Then
	 ii_codigo =dw_1.object.data[1,1]
Else
	il_codigo =dw_1.object.data[1,1]
End if		

end event

event rowfocuschanged;////-- Selecciona la fila actual
//this.selectrow(0,FALSE)
//this.selectrow(currentrow,TRUE)
//
////-- Retorna si fila no es valida
//if currentrow < 1 then return
//
////-- Ubica la fila actual
//this.setrow(currentrow)
//
////icurrentrow=currentrow
//
////-- Recupera el registro
////if not ib_m_tab then
//this.event dynamic ue_retrieve(icurrentrow)
//
If This.RowCount() = 0 Then Return

This.SelectRow(0,FALSE)
This.SelectRow(currentrow,TRUE)
This.ScrollToRow(currentrow)
//istr_parm.string_parm[1] = This.GetItemString(currentrow,'cc_artic')
//If istr_parm.datawindow_parm[1].dataobject = 'd_m_ldactzna'  Then
//	istr_parm.string_parm[2] = This.GetItemString(currentrow,'cd_artic')
//End If	
//

end event

event doubleclicked;string ls_columna
if right(string(dwo.name),2)='_t' then
	ls_columna = string(dwo.name)
	setsort(mid(ls_columna, 1, (len(ls_columna)-2))+' D')
	sort()
end if

if row < 1 then return

//icurrentrow=row

this.selectrow(0,FALSE)
this.selectrow(row,TRUE)

this.event dynamic ue_retrieve(row)

cb_aceptar.triggerevent( clicked!)


end event

type cb_aceptar from commandbutton within w_tablas_help
integer x = 1673
integer y = 1396
integer width = 402
integer height = 112
integer taborder = 30
boolean bringtotop = true
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "&Aceptar"
end type

event clicked;
istr_parm.char_parm[1]='1'
cb_cancelar.event post clicked()

if dw_1.rowcount() <= 0 then
	istr_parm.char_parm[1]='0'
end if
end event

